﻿using demo.Models;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace demo.Data
{
    public class AppDbContext : DbContext
    {
        public DbSet<Product> Product { get; set; }
        public DbSet<Category> Category { get; set; }
        public DbSet<SubCategory> SubCategory { get; set; }
        public DbSet<Warehouse> Warehouse { get; set; }
        public DbSet<Inventory> Inventory { get; set; }
        public DbSet<StockInOrder> StockInOrder { get; set; }
        public DbSet<StockInDetail> StockInDetail { get; set; }
        public DbSet<StockOutOrder> StockOutOrder { get; set; }
        public DbSet<StockOutDetail> StockOutDetail { get; set; }

        public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<StockInDetail>()
                .HasKey(o =>o.DetailID); 
            modelBuilder.Entity<StockInOrder>()
                .HasKey(o => o.OrderID);
            modelBuilder.Entity<StockOutOrder>()
    .HasKey(o => o.OrderID);
            modelBuilder.Entity<StockOutDetail>()
    .HasKey(o => o.DetailID);
        }
        //搞个map函数 定义映射 map实体 当前要管理的实体   include函数 实体外键
    }
}
